[#ftl]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加角色</title>
<link rel="stylesheet" type="text/css" href="${base}/css/date.css" />
<link rel="stylesheet" type="text/css" href="${base}/css/base.css" />
<link rel="stylesheet" type="text/css" href="${base}/css/form.css" />
<link rel="stylesheet" type="text/css" href="${base}/commonjs/ztree/css/zTreeStyle/zTreeStyle.css" />
<link rel="stylesheet" type="text/css" href="${base}/css/pop.css" />

<css>
<link rel="stylesheet" type="text/css" href="${base}/commonjs/ztree/css/zTreeStyle/zTreeStyle.css" />
</css>
<script type="text/javascript" src="${base}/commonjs/jquery1.7.2/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="${base}/commonjs/jquery-forms.js"></script>
<script type="text/javascript" src="${base}/commonjs/message/message.js"></script>
<script type="text/javascript" src="${base}/commonjs/noty/jquery.noty.packaged.min.js"></script>
<script type="text/javascript" src="${base}/commonjs/jquery-validation/jquery.validate.min.js" ></script>
<script type="text/javascript" src="${base}/commonjs/jquery-validation/localization/messages_zh.js" ></script>
<script type="text/javascript" src="${base}/commonjs/tab/tabs.js"></script>
<script type="text/javascript" src="${base}/commonjs/ztree/js/jquery.ztree.all-3.5.min.js" ></script>
<style type="text/css">
ul.ztree {
    margin-top: 10px;
    border: 1px solid #617775;
    width:300px;
    height:400px;
    overflow-y:scroll;
    overflow-x:auto;
}
</style>

<script type="text/javascript"> 

 var g_resourcesid = [];
 
 
 function getCheckedResources() {
    var checkedResources=[];
    var treeObj=$.fn.zTree.getZTreeObj("resouceTree");
    var nodes=treeObj.getCheckedNodes(true);
     
    for(var i=0;i<nodes.length;i++){
       checkedResources.push(nodes[i].id);//获取选中节点的值
    }
    //alert(checkedResources);
    return checkedResources;
};
 
$(document).ready(function(){
       
        $("#butSave").click(function(){ 
             $("#dataform").submit();           
         });
         
         $("#submitRoles").click(function(){ 
            $("#eva_all li a").removeClass().addClass("white");
            $("#eva_all li:first").removeClass().addClass("eva_focus");
            $("#eva_tab2").hide();
            $("#eva_tab1").show();
        }); 
        [#------------------------------------------------------------------]
        var v = jQuery("#dataform").validate({
            submitHandler: function(form) {
                var checkedResources = getCheckedResources();
                $(form).ajaxSubmit({
                    url:"${base}/system/role/add",
                    data:{"resourcesid":checkedResources},
                    success: function(data){  
                            noty({
                                  text:extendMessages(data).msg.message,
                                  layout:"center",
                                  timeout:2000,
                                  callback:{
                                     afterClose:function(){
                                        window.parent.location.reload(); 
                                     }
                                   }
                            });
                    }
                });
           }
        });
        
        $("#butCancel").click(function(){
            window.parent.closeArtDialog();
        });
        
});

$(document).ready(function(){
    var setting = {
            view: {
                selectedMulti: false
            },
            async: {
                enable: true,
                url:"${base}/system/childResources",
                autoParam:["id"],
                dataFilter: filter
            },
            check: {
                enable: true,
                chkStyle: "checkbox",
                chkboxType : { "Y" : "s", "N" : "ps" }
            },
        };
    
    function filter(treeId, parentNode, childNodes) {
        if (!childNodes) return null;
        for (var i=0, l=childNodes.length; i<l; i++) {
            childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
        }
        return childNodes;
    }

 
    $.fn.zTree.init($("#resouceTree"), setting);
     
});
</script>

</head>
<body>
<!-- 主体开始 -->
<div class="dataForm">
		<div class="eva_content_top">
			<ul id="eva_all">
				<li><a tab="eva_tab1" class="eva_focus" href="javascript:void(0);">基本信息</a></li>
				<li><a tab="eva_tab2" class="white" href="javascript:void(0);">分配资源</a></li>
			</ul>
		</div>
		<div id="eva_tab1" class="eva_tab">
			<form id="dataform" action="add" method="post">
				<div class="content mt10">
					<dl>
					<dt><span   class="required">*</span>名称</dt>
					<dd>			
					<input  class="required " name="name" id="name"  type="text" />
					</dd>			
					<dt><span   class="required">*</span>值</dt>
					<dd>			
					<input  class="required "  name="value" id="value"  type="text"  />
					</dd>
					
					<dt>备注</dt>
					<dd>
						<textarea rows="5" cols="38" id="description" name="description" ></textarea>
					</dd>
					<dl>
		
					<div class="clear"></div>
				</div>
				<div class="pop_btn">
					<input type="button" id="butSave" class="btn_1" value="保存"/>
					<input type="button" id="butCancel" class="btn_1" value="取消"/>
			    </div>
			</form>	
			</div>	
		<div id="eva_tab2" class="eva_tab">
				<div class="userole">
					<div class="mt10"><span   class="required">*</span>可选资源：</div>										
					<div class="pl60 f12 lh36">
                        <ul id="resouceTree" class="ztree"></ul>
                    </div>	
					<div class="clear"></div>
				</div>			
		</div>								
</div>

</body>
</html>